import { toast } from "../../../utils/storage"
Page({
  data: {
    homework: {}
  },
  async onLoad({ id }) {
    let { statusCode, data: { code, message, data: homework } } = await wx.$http.post(`/quality/student/studentQueryWorkForAct?actId=${id}`);
    if (statusCode === 200 && code === 200) {
      if (typeof (homework.evaluationSignInTime) === "string")
        homework.evaluationSignInTime = JSON.parse(homework.evaluationSignInTime);
      if (typeof (homework.evaluationSignOutTime) === "string")
        homework.evaluationSignOutTime = JSON.parse(homework.evaluationSignOutTime);
      if (typeof (homework.evaluationImageUrls) === "string")
        homework.evaluationImageUrls = JSON.parse(homework.evaluationImageUrls);
      if (typeof homework.remarks === "string")
        homework.remarks = JSON.parse(homework.remarks);
      homework.imageFailText = homework.remarks?.find(x => x.evaluationType == 3)?.failedText;
      homework.remarkFailText = homework.remarks?.find(x => x.evaluationType == 4)?.failedText;
      homework.fileFailText = homework.remarks?.find(x => x.evaluationType == 5)?.failedText;
      this.setData({ homework });
    }
    else
      toast({ title: message || "操作失败，请重试" });
  },
  goback() {
    wx.navigateBack();
  }
})